import React, { Component } from 'react';
import Nav from '../components/base/Nav';
import TopBar from '../components/base/TopBar';
import RouteWithSubRoutes from '../components/base/RouteWithSubRoutes';

class App extends Component {
  constructor(props) {
    super(props);
    
    this.state = {
      navData: [
        {
          name: '商品管理',
          iconClass: 'el-icon-message',
          children: [
            {
              name: '商品列表',
              link: '/goodsList'
            }
          ]
        },
        {
          name: '优惠券管理',
          iconClass: 'el-icon-message',
          children: [
            {
              name: '优惠券列表',
              link: '/discountList'
            }
          ]
        },
        {
          name: '售后',
          iconClass: 'el-icon-message',
          children: [
            {
              name: '售后申请管理',
              link: '/afterSalesList'
            },
            {
              name: '退换货管理',
              link: '/returnList'
            },
            {
              name: '退款管理',
              link: '/refundList'
            },
            {
              name: '退换货原因管理',
              link: '/returnReasonList'
            }
          ]
        },
        {
          name: '订单',
          iconClass: 'el-icon-message',
          children: [
            {
              name: '订单管理列表',
              link: '/orderManage'
            },
            {
              name: '发货订单列表',
              link: '/shipmentOrder'
            },
            {
              name: '派件订单列表',
              link: '/deliveryOrder'
            }
          ]
        },
        {
          name: '商家管理',
          iconClass: 'el-icon-message',
          children: [
            {
              name: '商家列表',
              link: '/sellerList'
            }
          ]
        },          
        {
          name: '会员管理',
          iconClass: 'el-icon-message',
          children: [
            {
              name: '会员',
              link: '/memberList'
            }
          ]
        }
      ]
    };
  }
  
  render() {
    let routes = this.props.routes;
    
    return (
      <div className="height">
        <TopBar/>
        <div className="container">
          <div><Nav data={this.state.navData}/></div>
          <div className="routerView" ref="routerV">
            {routes.map((route, i) => (
                <RouteWithSubRoutes key={i} {...route}/>
            ))}
          </div>
        </div>
      </div>
    );
  }
}

export default App;